package com.ruoyi.Warehouse.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.Warehouse.domain.Inventorychecks;
import com.ruoyi.Warehouse.service.IInventorychecksService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库存盘点记录表Controller
 * 
 * @author ruoyi
 * @date 2025-06-16
 */
@Controller
@RequestMapping("/pims/inventorychecks")
public class InventorychecksController extends BaseController
{
    private String prefix = "pims/inventorychecks";

    @Autowired
    private IInventorychecksService inventorychecksService;

    @RequiresPermissions("pims:inventorychecks:view")
    @GetMapping()
    public String inventorychecks()
    {
        return prefix + "/inventorychecks";
    }

    /**
     * 查询库存盘点记录表列表
     */
    @RequiresPermissions("pims:inventorychecks:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Inventorychecks inventorychecks)
    {
        startPage();
        List<Inventorychecks> list = inventorychecksService.selectInventorychecksList(inventorychecks);
        return getDataTable(list);
    }

    /**
     * 导出库存盘点记录表列表
     */
    @RequiresPermissions("pims:inventorychecks:export")
    @Log(title = "库存盘点记录表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Inventorychecks inventorychecks)
    {
        List<Inventorychecks> list = inventorychecksService.selectInventorychecksList(inventorychecks);
        ExcelUtil<Inventorychecks> util = new ExcelUtil<Inventorychecks>(Inventorychecks.class);
        return util.exportExcel(list, "库存盘点记录表数据");
    }

    /**
     * 新增库存盘点记录表
     */
    @RequiresPermissions("pims:inventorychecks:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存库存盘点记录表
     */
    @RequiresPermissions("pims:inventorychecks:add")
    @Log(title = "库存盘点记录表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Inventorychecks inventorychecks)
    {
        return toAjax(inventorychecksService.insertInventorychecks(inventorychecks));
    }

    /**
     * 修改库存盘点记录表
     */
    @RequiresPermissions("pims:inventorychecks:edit")
    @GetMapping("/edit/{checkId}")
    public String edit(@PathVariable("checkId") Long checkId, ModelMap mmap)
    {
        Inventorychecks inventorychecks = inventorychecksService.selectInventorychecksByCheckId(checkId);
        mmap.put("inventorychecks", inventorychecks);
        return prefix + "/edit";
    }

    /**
     * 修改保存库存盘点记录表
     */
    @RequiresPermissions("pims:inventorychecks:edit")
    @Log(title = "库存盘点记录表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Inventorychecks inventorychecks)
    {
        return toAjax(inventorychecksService.updateInventorychecks(inventorychecks));
    }

    /**
     * 删除库存盘点记录表
     */
    @RequiresPermissions("pims:inventorychecks:remove")
    @Log(title = "库存盘点记录表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(inventorychecksService.deleteInventorychecksByCheckIds(ids));
    }
}
